﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace PJ.Repository.DBModel
{
    public partial class zlwebContext : DbContext
    {
        public zlwebContext()
        {
        }

        public zlwebContext(DbContextOptions<zlwebContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Button> Button { get; set; }
        public virtual DbSet<Donation> Donation { get; set; }
        public virtual DbSet<Items> Items { get; set; }
        public virtual DbSet<Itemsdetail> Itemsdetail { get; set; }
        public virtual DbSet<Logonlog> Logonlog { get; set; }
        public virtual DbSet<Module> Module { get; set; }
        public virtual DbSet<Organize> Organize { get; set; }
        public virtual DbSet<Role> Role { get; set; }
        public virtual DbSet<Roleauthorize> Roleauthorize { get; set; }
        public virtual DbSet<Taskschedule> Taskschedule { get; set; }
        public virtual DbSet<Users> Users { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder.UseSqlServer("Server=.;Database=zlweb;User ID=sa;Password=123;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Button>(entity =>
            {
                entity.ToTable("button");

                entity.HasComment("按钮表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.ClassName)
                    .HasMaxLength(50)
                    .HasComment("按钮样式");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.CreateUserId).HasComment("创建用户主键");

                entity.Property(e => e.EnCode)
                    .HasMaxLength(50)
                    .HasComment("编码");

                entity.Property(e => e.FullName)
                    .HasMaxLength(50)
                    .HasComment("名称");

                entity.Property(e => e.Icon)
                    .HasMaxLength(50)
                    .HasComment("图标");

                entity.Property(e => e.Location).HasComment("位置");

                entity.Property(e => e.SortCode).HasComment("排序码");

                entity.Property(e => e.UpdateTime).HasComment("修改时间");

                entity.Property(e => e.UpdateUserId).HasComment("修改用户主键");
            });

            modelBuilder.Entity<Donation>(entity =>
            {
                entity.ToTable("donation");

                entity.HasComment("捐赠表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.Detail)
                    .HasMaxLength(100)
                    .HasComment("备注");

                entity.Property(e => e.Name)
                    .HasMaxLength(50)
                    .HasComment("捐赠人");

                entity.Property(e => e.Price)
                    .HasMaxLength(50)
                    .HasComment("捐赠金额");

                entity.Property(e => e.Source)
                    .HasMaxLength(50)
                    .HasComment("捐赠方式");
            });

            modelBuilder.Entity<Items>(entity =>
            {
                entity.ToTable("items");

                entity.HasComment("字典表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.CreateUserId).HasComment("创建用户主键");

                entity.Property(e => e.EnCode)
                    .HasMaxLength(50)
                    .HasComment("编码");

                entity.Property(e => e.FullName)
                    .HasMaxLength(50)
                    .HasComment("名称");

                entity.Property(e => e.ParentId).HasComment("父级");

                entity.Property(e => e.SortCode).HasComment("排序码");

                entity.Property(e => e.UpdateTime).HasComment("修改时间");

                entity.Property(e => e.UpdateUserId).HasComment("修改用户主键");
            });

            modelBuilder.Entity<Itemsdetail>(entity =>
            {
                entity.ToTable("itemsdetail");

                entity.HasComment("字典明细表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.CreateUserId).HasComment("创建用户主键");

                entity.Property(e => e.ItemCode)
                    .HasMaxLength(50)
                    .HasComment("编码");

                entity.Property(e => e.ItemId).HasComment("主表主键");

                entity.Property(e => e.ItemName)
                    .HasMaxLength(50)
                    .HasComment("名称");

                entity.Property(e => e.SortCode).HasComment("排序码");

                entity.Property(e => e.UpdateTime).HasComment("修改时间");

                entity.Property(e => e.UpdateUserId).HasComment("修改用户主键");
            });

            modelBuilder.Entity<Logonlog>(entity =>
            {
                entity.ToTable("logonlog");

                entity.HasComment("登录日志表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.Account)
                    .HasMaxLength(50)
                    .HasComment("账户");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.Description)
                    .HasMaxLength(200)
                    .HasComment("描述");

                entity.Property(e => e.Ipaddress)
                    .HasColumnName("IPAddress")
                    .HasMaxLength(50)
                    .HasComment("IP地址");

                entity.Property(e => e.IpaddressName)
                    .HasColumnName("IPAddressName")
                    .HasMaxLength(50)
                    .HasComment("IP所在城市");

                entity.Property(e => e.LogType)
                    .HasMaxLength(50)
                    .HasComment("登录类型");

                entity.Property(e => e.RealName)
                    .HasMaxLength(50)
                    .HasComment("姓名");
            });

            modelBuilder.Entity<Module>(entity =>
            {
                entity.ToTable("module");

                entity.HasComment("模块表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.CreateUserId).HasComment("创建用户主键");

                entity.Property(e => e.FontFamily)
                    .HasMaxLength(50)
                    .HasComment("字体类型");

                entity.Property(e => e.FullName)
                    .HasMaxLength(50)
                    .HasComment("名称");

                entity.Property(e => e.Icon)
                    .HasMaxLength(50)
                    .HasComment("图标");

                entity.Property(e => e.ParentId).HasComment("父级");

                entity.Property(e => e.SortCode).HasComment("排序码");

                entity.Property(e => e.UpdateTime).HasComment("修改时间");

                entity.Property(e => e.UpdateUserId).HasComment("修改用户主键");

                entity.Property(e => e.UrlAddress)
                    .HasMaxLength(100)
                    .HasComment("链接");
            });

            modelBuilder.Entity<Organize>(entity =>
            {
                entity.ToTable("organize");

                entity.HasComment("组织表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.CategoryId).HasComment("分类");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.CreateUserId).HasComment("创建用户主键");

                entity.Property(e => e.EnCode)
                    .HasMaxLength(50)
                    .HasComment("编码");

                entity.Property(e => e.FullName)
                    .HasMaxLength(50)
                    .HasComment("名称");

                entity.Property(e => e.ParentId).HasComment("父级");

                entity.Property(e => e.SortCode).HasComment("排序码");

                entity.Property(e => e.UpdateTime).HasComment("修改时间");

                entity.Property(e => e.UpdateUserId).HasComment("修改用户主键");
            });

            modelBuilder.Entity<Role>(entity =>
            {
                entity.ToTable("role");

                entity.HasComment("角色表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.CreateUserId).HasComment("创建用户主键");

                entity.Property(e => e.EnCode)
                    .HasMaxLength(50)
                    .HasComment("编码");

                entity.Property(e => e.FullName)
                    .HasMaxLength(50)
                    .HasComment("名称");

                entity.Property(e => e.SortCode).HasComment("排序码");

                entity.Property(e => e.TypeClass).HasComment("类型");

                entity.Property(e => e.UpdateTime).HasComment("修改时间");

                entity.Property(e => e.UpdateUserId).HasComment("修改用户主键");
            });

            modelBuilder.Entity<Roleauthorize>(entity =>
            {
                entity.HasKey(e => new { e.RoleId, e.ModuleId, e.ButtonId })
                    .HasName("PK__roleauth__AAA20E5A419A02D8");

                entity.ToTable("roleauthorize");

                entity.HasComment("角色授权表");

                entity.Property(e => e.RoleId)
                    .HasMaxLength(10)
                    .IsFixedLength()
                    .HasComment("角色主键");

                entity.Property(e => e.ModuleId)
                    .HasMaxLength(10)
                    .IsFixedLength()
                    .HasComment("模块主键");

                entity.Property(e => e.ButtonId)
                    .HasMaxLength(10)
                    .IsFixedLength()
                    .HasComment("按钮主键");
            });

            modelBuilder.Entity<Taskschedule>(entity =>
            {
                entity.ToTable("taskschedule");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.CronExpress)
                    .IsRequired()
                    .HasMaxLength(255)
                    .HasComment("Cron表达式");

                entity.Property(e => e.EndRunTime).HasComment("停止时间");

                entity.Property(e => e.FileName)
                    .IsRequired()
                    .HasMaxLength(255);

                entity.Property(e => e.JobGroup)
                    .IsRequired()
                    .HasMaxLength(255)
                    .HasComment("任务组");

                entity.Property(e => e.JobName)
                    .IsRequired()
                    .HasMaxLength(255)
                    .HasComment("任务名称");

                entity.Property(e => e.StarRunTime).HasComment("启动时间");

                entity.Property(e => e.State).HasComment("0停止,1启动,2假删除");
            });

            modelBuilder.Entity<Users>(entity =>
            {
                entity.ToTable("users");

                entity.HasComment("用户表");

                entity.Property(e => e.Id).HasComment("主键");

                entity.Property(e => e.Account)
                    .HasMaxLength(50)
                    .HasComment("账户");

                entity.Property(e => e.Birthday).HasComment("生日");

                entity.Property(e => e.CreateTime).HasComment("创建时间");

                entity.Property(e => e.CreateUserId).HasComment("创建用户主键");

                entity.Property(e => e.DepartmentId).HasComment("部门主键");

                entity.Property(e => e.Email)
                    .HasMaxLength(50)
                    .HasComment("邮箱");

                entity.Property(e => e.EnabledMark).HasComment("有效标志");

                entity.Property(e => e.Gender).HasComment("性别");

                entity.Property(e => e.HeadIcon)
                    .HasMaxLength(50)
                    .HasComment("头像");

                entity.Property(e => e.MobilePhone)
                    .HasMaxLength(50)
                    .HasComment("手机");

                entity.Property(e => e.RealName)
                    .HasMaxLength(50)
                    .HasComment("姓名");

                entity.Property(e => e.RoleId).HasComment("角色主键");

                entity.Property(e => e.UpdateTime).HasComment("修改时间");

                entity.Property(e => e.UpdateUserId).HasComment("修改用户主键");

                entity.Property(e => e.UserPassword)
                    .HasMaxLength(50)
                    .HasComment("密码");

                entity.Property(e => e.WeChat)
                    .HasMaxLength(50)
                    .HasComment("微信");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
